package com.studentmanager.service.Impl;

import com.studentmanager.domain.learningunit;
import com.studentmanager.mapper.learningunitMapper;
import com.studentmanager.service.learnunitservice;
import com.studentmanager.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class learnunitserviceimpl implements learnunitservice {
    @Autowired
    private learningunitMapper learnunitMapper;


    @Override
    public int addUnit(learningunit learningunit){
        return learnunitMapper.addUnit(learningunit);
    }

    @Override
    public int editUnit(learningunit courseLearnUnit) {
        return 0;
    }

    @Override
    public int deleteUnits(List<Integer> ids) {
        return 0;
    }


    @Override
    public PageBean<learningunit> queryPage(Map<String, Object> paramMap) {
        PageBean<learningunit> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<learningunit> datas = learnunitMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize =learnunitMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

}
